﻿using Microsoft.AspNetCore.Mvc.Filters;

namespace Enterprise_Get.API.Filter
{
    public class ComExceptionFilter : IExceptionFilter
    {
        private readonly NLog.ILogger _logger = NLog.LogManager.GetCurrentClassLogger();
        public void OnException(ExceptionContext context)
        {
            //Nlog记录错误日志
            _logger.Error(context.Exception, $"全局异常过滤器记录:{context.Exception.Message}");

            //异常已处理
            //context.ExceptionHandled = true;
        }
    }
}
